import React from 'react'
import { Icon, Button, Checkbox } from 'antd';
import styles from './../youkee.less'
const CheckboxGroup = Checkbox.Group;
//表格右上角的按钮组
const TableButton = (props) => {
  const {optList, handles, isModal, checkOptions, checkChange, checkTitle} = props;

  return <div className={isModal?styles['uk_table_btns_modal']:styles['uk_table_btns']}>
    {checkTitle ?
      <div className={styles.checkGroupBox}>
        <span className={styles.checkGroupS}>{checkTitle+"："}</span>
        <span className={styles.checkGroupS}>
         <CheckboxGroup options={checkOptions} defaultValue={[]} onChange={checkChange}/>
        </span>
      </div>
      : null}

    <Button.Group size='Large'>
      {optList.map(function (item, key) {
        if(item.type === 'link'){
          if(item.canRender !== undefined && item.canRender === false) return null;
          return <Button type="default" key={key}>
            <a href={item.url}>
              <Icon type={item.icon}/>{item.text}
            </a>
          </Button>
        }else{
          if(item.canRender !== undefined && item.canRender === false) return null;
          return <Button type="default" key={key} onClick={handles[item.type + 'Handle'] || null}>
            <Icon type={item.icon}/>{item.text}
          </Button>
        }
      })}
    </Button.Group>
    {props.children}
  </div>
}

export default TableButton
